<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button>跳转按钮</button>
    <button>前进按钮</button>
    <button>后退按钮</button>

    <script>
        //history对象 历史记录 地址栏操作
        //back() 后退
        //forword() 前进
        //go() -1后退 1前进
        const but = document.querySelectorAll('button')[0];
        console.log(but);
        but.addEventListener('click', function () {
            location.href = 'https://www.baidu.com';
        })
        but.nextElementSibling.addEventListener('click', function () {
            console.log('前进');
            history.go(1);
        })
        but.nextElementSibling.nextElementSibling.addEventListener('click', function () {
            console.log('后退');
            history.go(-1);
        })
    </script>
</body>

</html>